Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore previous shader program on nvgEndFrame #622

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

clinthidinger
Copy link

This change restores the previous shader program instead of setting it to 0 on nvgEndFrame()/renderFlush().

This will also help when using nanovg with other graphics libraries that manage a default shader like Cinder.

@mulle-nat
Copy link
Contributor

On one hand this seems like an improvement, but on the other hand isn't there a lot of other state clobbered by nvg ? Only partial restoration of the previous state may lead to other subtle or not so subtle bugs. Just my thoughts on this...

@clinthidinger
Copy link
Author

You're right about other states being clobbered. I should have looked through the README more closely in the part where it describes the states that get touched.

However, I think it may be worth considering preserving the program state since it seems common for other graphics libraries to try to simulate a default shader. The change to this state was actually causing an OpenGL error (GL_INVALID_OPERATION) from drawing with a null program handle when I called draw on a 3D object in Cinder after a call to nvgEndFrame(). It was also difficult to track down what the problem was until I used glEnable( GL_DEBUG_OUTPUT ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants